<template>
	<div class="index">

		<div class="center">
			<left></left>
			<div class="right">
          <top></top>
          <div class="hei10"></div>

          <div class="where" style="background: #fff; padding: 10px 30px; font-size: 14px; color: #595959;">
            当前位置：
            <router-link to="/index" style="color: #409eff;">分销后台</router-link>>
            <router-link to="/productionDelivery" style="color: #409eff;">在售商品管理</router-link>>
            修改商品
          </div>

          <div class="hei10"></div>
<div class="addpro">
					<div class="step" v-loading='loading'>
						<div class="tilte">修改商品销售页信息</div>
						<div class="con">
							<el-form ref="form" :rules="rules" @submit.native.prevent :model="shopform"
								label-width="180px">

								<el-form-item label="选择产品方式：">
									<el-select v-model="semod" filterable disabled placeholder="请选择">
										<el-option label="基于自有产品选择" value="1"></el-option>
										<el-option label="基于上游产品选择" value="2"></el-option>
									</el-select>
								</el-form-item>
								<el-form-item label="选择产品：" prop="proid">
									<div class="basispro" v-if="semod == 1">
										<el-select v-model="proid" filterable disabled placeholder="请选择产品">
											<el-option v-for="(item,index) in prolists" :key="index" :label="item.name"
												:value="item.id"></el-option>
										</el-select>
										<el-checkbox style="margin-left: 20px;" v-if="this.shop_id == 50481 || this.shop_id == 304676" v-model="isxn">引流商品</el-checkbox>

									</div>
									<div class="basispro" v-if="semod == 2">
										<el-select v-model="shopid" disabled filterable placeholder="请选择商品">
											<el-option v-for="(item,index) in shoplists" :key="index"
												:label="item.title" :value="item.id"></el-option>
										</el-select>
										<el-checkbox style="margin-left: 20px;" v-if="this.shop_id == 50481 || this.shop_id == 304676" v-model="isxn">引流商品</el-checkbox>

									</div>

								</el-form-item>

                <div class="flex w330" style="align-items: center; margin-bottom: 22px;" prop="sign_type"  v-if="shop_id == 304676 || shop_id == 50481">
                	<el-form-item label="选择签约方式:" prop="title" style="margin-bottom: 0px;">
                		<el-radio v-model="shopform.sign_type" :label="1">直签</el-radio>
                		<el-radio v-model="shopform.sign_type" :label="2">代理</el-radio>
                	</el-form-item>
                </div>

                <div class="flex w330" style="align-items: center; margin-bottom: 22px;">
                	<el-form-item label="商品名称:" prop="title" style="margin-bottom: 0px;">
                		<el-input v-model="shopform.title" :class="{redbor:!sub3}" @change="nijiushiwodeweiyi3" placeholder="不超过30个字"></el-input>
                	</el-form-item>
                  <el-tooltip class="item" effect="light" content="对外展示的产品标题，能清晰描述概括产品，例：北京19元月租大王卡赠2GB流量" placement="top">
                    <i class="el-icon-question" style="color: rgb(64, 155, 250); font-size: 25px; margin-left: 20px; cursor: pointer;"></i>
                  </el-tooltip>
                </div>

								<el-form-item label="商家编码（抓单标识）:" prop="randomnum">
                  <div style="display: flex; align-items: center;">
                    {{randomnum}}
                    <el-button plain type="primary" size="small" style="margin: 0 10px;" @click="randomlog = true">自定义</el-button>
                    <el-tooltip class="item" effect="light" content="如果要使用自动抓单系统的话，请在电商平台将该码粘贴到产品后台的“货号（商品编码）”处。每个产品都有唯一标识"
                     placement="top">
                    	<i class="el-icon-question" style="color: rgb(64, 155, 250); font-size: 25px;  cursor: pointer;"></i>
                    </el-tooltip>
                  </div>
								</el-form-item>

								<!-- <el-form-item label="京东特有(必须三位):" style="width: 450px;">
									<el-input v-model="jingdongrandom" maxlength="3" :class="{redbor:!sub4}"
										@input="nijiushiwodeweiyi4" placeholder="请输入京东特用抓单码"></el-input>
								</el-form-item> -->

                <div class="flex w330" style="align-items: center; margin-bottom: 0px;">
                	<el-form-item label="商品注意点:">
                		<el-input v-model="shopform.points" placeholder="输入商品注意点"></el-input>
                	</el-form-item>
                </div>

								<div class="flex w330" style="align-items: center; margin-bottom: 22px;">
									<el-form-item label="商品卖点:" style="margin-bottom: 0px;">
										<el-input v-model="shopform.selling_point" placeholder="输入卖点，使用逗号隔开"></el-input>
									</el-form-item>
									<el-tooltip class="item" effect="light" content="不超过3组词，例：资费低，流量大，免月租等，不宜过长" placement="top">
										<i class="el-icon-question" style="color: rgb(64, 155, 250); font-size: 25px;  margin-left: 20px; cursor: pointer;"></i>
									</el-tooltip>
								</div>

                <div class="flex">
                	<el-form-item>
                    <template slot="label">
                      <span style="color: #f00; margin-right: 5px;" v-if="shop_id == 50481 || shop_id == 304676">*</span><span>承接佣金规则</span>
                    </template>
                    <div class="kflexc">
                      <div style="width: 330px;"><el-input v-model="shopform.expect_income_new" placeholder="承接佣金规则"></el-input></div>
                      <div style="color: rgb(64, 155, 250); margin-left: 20px; cursor: pointer;" @click="yugulog = true" >生效时间</div>
                      <div style="color: rgb(64, 155, 250); margin-left: 20px; cursor: pointer;" @click="xiugaijilukai2" >修改记录</div>
                    </div>
                	</el-form-item>
                </div>

                <el-dialog title="承接佣金规则定时生效" :visible.sync="yugulog" width="480px"  :close-on-click-modal="false" :close-on-press-escape="false">
                	  <div>
                      <el-input v-model="shopform.change_expect_income"  placeholder="承接佣金规则生效内容"></el-input>
                    </div>
                    <div>
                      <el-date-picker type="datetime" v-model="shopform.expect_income_change_at" value-format="yyyy-MM-dd HH:mm:ss" style="margin-bottom: 20px; width: 100%; margin-top: 20px;" placeholder="承接佣金规则生效时间"></el-date-picker>
                    </div>
                	  <span slot="footer" class="dialog-footer">
                      <el-button type="primary" @click="yugulog = false">确 定</el-button>
                	  </span>
                </el-dialog>

                <div class="flex">
                	<el-form-item label="预估收益:">
                    <div class="kflexc">
                      <div style="width: 330px;"><el-input v-model="shopform.estimated_income" placeholder="预估收益"></el-input></div>
                    </div>
                	</el-form-item>
                </div>

								<div class="flex">
									<el-form-item label="结算要求:">
								    <div class="kflexc">
								      <div style="width: 330px;"><el-input v-model="shopform.commission_rule" placeholder="对外展示"></el-input></div>
								      <!-- <div style="color: rgb(64, 155, 250); margin-left: 20px; cursor: pointer;" @click="jiesuanlog = true" >生效时间</div> -->
								    </div>
									</el-form-item>
								</div>
								<!-- <el-dialog title="结算规则定时生效" :visible.sync="jiesuanlog" width="480px"  :close-on-click-modal="false" :close-on-press-escape="false">
									  <div>
								      <el-input v-model="shopform.change_commission_rule"  placeholder="结算规则生效内容"></el-input>
								    </div>
								    <div>
								      <el-date-picker type="datetime" v-model="shopform.commission_rule_change_at" size="medium" value-format="yyyy-MM-dd HH:mm:ss" style="margin-bottom: 20px; width: 100%; margin-top: 20px;" placeholder="结算规则生效时间"></el-date-picker>
								    </div>
									  <span slot="footer" class="dialog-footer">

								      <el-button type="primary" @click="jiesuanlog = false">确 定</el-button>
									  </span>
								</el-dialog> -->
								<div class="flex"  v-if="checkquanxian('P0209').length > 0">
									<el-form-item label="佣金结算规则（内部）:">
								    <div class="kflexc">
								      <div style="width: 330px;"><el-input v-model="shopform.commission_notes" style="width: 330px;" placeholder="佣金结算规则（内部）"></el-input></div>
								      <div style="color: rgb(64, 155, 250); margin-left: 20px; cursor: pointer;" @click="jiesuanlog2 = true" >生效时间</div>

                      <div style="color: rgb(64, 155, 250); margin-left: 20px; cursor: pointer;" @click="xiugaijilukai" >修改记录</div>
								    </div>
									</el-form-item>
								</div>
								<el-dialog title="佣金结算规则（内部）" :visible.sync="jiesuanlog2" width="480px"  :close-on-click-modal="false" :close-on-press-escape="false">
									  <div>
								      <el-input v-model="shopform.change_commission_notes"  placeholder="佣金结算规则（内部）"></el-input>
								    </div>
								    <div>
								      <el-date-picker type="datetime" v-model="shopform.commission_notes_change_at" size="medium" value-format="yyyy-MM-dd HH:mm:ss" style="margin-bottom: 20px; width: 100%; margin-top: 20px;" placeholder="结算规则生效时间"></el-date-picker>
								    </div>
									  <span slot="footer" class="dialog-footer">

								      <el-button type="primary" @click="jiesuanlog2 = false">确 定</el-button>
									  </span>
								</el-dialog>

								<!-- <div class="flex">
									<el-form-item label="拆单设置:">
										<div class="flex" style="align-items: center;">
											<el-select v-model="cd_number" :disabled="allshow" filterable
												placeholder="请选择拆单数量" @change="changenumber">
												<el-option label="不拆单" value="0"></el-option>
												<el-option v-for="(item,index) in 5" :key="index" :label="item"
													:value="item"></el-option>
											</el-select>
											<el-tooltip class="item" effect="light"
												content="一单多发，单个订单给用户发货多个商品，系统会在您指定的时间执行自动拆单，拆单后的订单将按照商品编码自动匹配，并重新走审核生产流程"
												placement="top">
												<i class="el-icon-question" style="color: rgb(64, 155, 250); font-size: 25px;  margin-left: 20px; cursor: pointer;"></i>
											</el-tooltip>

										</div>
										<el-radio-group v-if="cd_number!='0'" v-model="cd_type_radio">
											<el-radio :label="3">符合条件拆单</el-radio>
											<el-radio :label="4">指定时间拆单</el-radio>
										</el-radio-group>

										<div v-for="(item,index) in split_list" :key="index"
											style="background: #f1f1f1; padding: 20px; margin-top:10px; border: 1px #ccc solid; color: #999; border-radius: 3px;">

											<div v-if="cd_type_radio==3">
												<div>拆分订单{{index+1}}<span v-if="index == 0"
													style="color: #409EFF;">(非原订单)</span>
												</div>
												<div style="padding-left: 13px;">
													当“<span v-if="index == 0">原订单</span><span v-else>拆分订单{{index}}</span>”订单状态变更为“<span style="color: #EEF7FF;">生产失败</span>“时，则执行本次拆单<span style="color: #AFAFAF;">（每10分钟执行一次）</span>
												</div>
												<div class="flex">
													<div style="width: 140px; text-align: right; margin-right: 20px;">拆分订单所属商品：</div>
													<div>
														<el-input v-model="item.sku" style="width: 250px;" placeholder="商品编码"></el-input>
													</div>
												</div>
											</div>

											<div v-if="cd_type_radio==4" >
												<div>拆分订单{{index+1}}<span v-if="index == 0"
													style="color: #409EFF;">(非原订单)</span></div>
												<div class="flex">
													<div style="width: 140px; text-align: right; margin-right: 20px;">拆单执行时间：</div>
													<div class="zidong">原订单进入{{moban.platform_name}}系统<el-input v-model="item.later" min="0" type="number" style="width: 100px; margin: 0 10px;">
														</el-input>小时后拆单</div>
												</div>
												<div class="flex">

													<div style="width: 140px; text-align: right; margin-right: 20px;">拆分订单所属商品：</div>
													<div>
														<el-input v-model="item.sku" style="width: 250px;" placeholder="商品编码"></el-input>
													</div>
												</div>
												<div class="flex">
													<div style="width: 140px; text-align: right; margin-right: 20px;">拆单前检测：</div>
													<div>
														<el-checkbox v-model="item.check_deliver">拆分执行时，若
															<span style="color: #409EFF;" v-if="index == 0">原订单</span>
															<span style="color: #409EFF;"
																v-if="index != 0">拆分订单{{index}}</span>

															已发货成功，则该订单不再拆分
														</el-checkbox>
													</div>
												</div>
											</div>



										</div>

										<div v-if="cd_number!='0'">
											<div v-if="cd_type_radio==3" style="color: #B4B4B4; line-height: 35px;">
												<div>拆单说明：</div>
												<div>1、反复失败的订单只会在第一次失败拆分，后续失败不会拆分</div>
												<div>2、若”拆分订单1”不满足条件未拆分，则后续拆分订单2、3都不会执行拆分</div>
												<div>3、拆分订单为独立订单与原订单没有关联关系</div>
												<div>4、拆分定单在外部订单号后增加”-CF1”字样用以区分</div>
											</div>

											<div v-if="cd_type_radio==4" style="color: #B4B4B4; line-height: 35px;">
												<div>拆单说明：</div>
												<div>1、拆分订单1、2同时勾选“拆单前检测”后“拆分订单1”拆单失败不影响“拆分订单2”的拆单，拆分订单2会成功拆单。</div>
												<div>2、拆分后的订单完全独立，原订单执行删除、修改订单状态等不会影响拆分订单</div>
												<div>3、拆单功能只针对自己发展的订单，无法拆单分销商发展订单</div>
												<div>4、拆分订单不会去电商平台同步发货信息，只在{{moban.platform_name}}有发货记录</div>
											</div>
										</div>

									</el-form-item>
								</div> -->

								<!-- <zdzd  @changesw="changesw" @surecreate="surecreate" @handleChange="handleChange" :wwidth="'330px'" :auto_transfer="this.shopform.auto_transfer" :auto_transfer_pages="this.shopform.auto_transfer_pages" :auto_transfer_sources="this.shopform.auto_transfer_sources"  ></zdzd> -->
								<el-form-item label="销售页上传照片:">
                  <div style="display: flex; align-items: center;">
                    <el-radio-group v-model="shopform.is_need_photo" prop="is_need_photo">
                    	<el-radio label="0">无需上传</el-radio>
                    	<el-radio label="1">需要上传</el-radio>
                    </el-radio-group>
                    <el-tooltip class="item" effect="light"
                    	content="仅设置是否需要在销售页下单时上传照片，选择无需上传可在批量上传照片处另行导入。" placement="top">
                    	<i class="el-icon-question" style="color: rgb(64, 155, 250); font-size: 25px;  margin-left: 20px; cursor: pointer;"></i>
                    </el-tooltip>
                  </div>

								</el-form-item>
								<div class="flex">
									<el-form-item label="产品主图:">
										<!-- <el-upload class="avatar-uploader"
											action="https://jsonplaceholder.typicode.com/posts/" :on-change="uploadok"
											:auto-upload="false" :show-file-list="false">
											<img v-if="shopform.image1" :src="shopform.image1" class="avatar">
											<i v-else class="el-icon-plus avatar-uploader-icon"></i>
										</el-upload> -->
                    <chuantu2 v-if="chuantushow" ref="chuantu" :imgs="shopform.image1" @getimg="getimg"></chuantu2>
									</el-form-item>
								</div>
								<div class="flex" style="align-items: center;">
									<el-form-item label="商品分享图:">
										<!-- <el-upload class="avatar-uploader" action="https://jsonplaceholder.typicode.com/posts/" :on-change="uploadok2"
										 :auto-upload="false" :show-file-list="false">
											<img v-if="shopform.share_img" :src="shopform.share_img" class="avatar">
											<i v-else class="el-icon-plus avatar-uploader-icon"></i>
										</el-upload> -->
                    <chuantu v-if="chuantushow" ref="chuantu" :imgs="shopform.share_img" @getimg="getimg2"></chuantu>
									</el-form-item>
								  <el-tooltip class="item" effect="light" content="该图用于微小店分享商品处向用户说明产品优点。" placement="top">
								    <i class="el-icon-question" style="color: rgb(64, 155, 250); font-size: 25px;  margin-left: 20px; cursor: pointer;"></i>
								  </el-tooltip>
								</div>
								<el-form-item label="商品详情:" prop="edit">
									<div id="editor">

									</div>
								</el-form-item>
								<el-form-item label="其他备注:">
									<div id="editorE">

									</div>
								</el-form-item>

								<!-- <el-form-item label="修改摘要:">
									<el-input type="textarea" v-model="abstract"></el-input>
								</el-form-item> -->
								<el-form-item label="强制同步:" v-if="force_updateshow">
									<el-checkbox v-model="force_update" @change="changeforce_update">强制同步分销商此商品详情页
									</el-checkbox>
								</el-form-item>

                <!-- //新增模块 -->
                <div>
                  <div style="padding: 20px 0; font-size: 16px; font-weight: bold;">套餐详情</div>

                	<el-form-item label="月租：">
                		<el-input v-model="shopform.yuezu" placeholder="请输入月租"></el-input>
                	</el-form-item>
                  <el-form-item label="语音通话：">
                  	<el-input v-model="shopform.yuyin" placeholder="请输入语音通话"></el-input>
                  </el-form-item>
                	<el-form-item label="通用流量：">
                		<el-input v-model="shopform.liuliang" placeholder="请输入通用流量"></el-input>
                	</el-form-item>
                	<el-form-item label="定向流量：">
                		<el-input v-model="shopform.dx_liuliang" placeholder="请输入定向流量"></el-input>
                	</el-form-item>
                  <el-form-item label="归属地：">
                    <dizhi @xuanzhongde="xuanzhongde" :guishudi_code="shopform.guishudi_code"></dizhi>
                  </el-form-item>

                  <el-form-item label="套餐详细信息:">
                  	<div id="editorE2">

                  	</div>
                  </el-form-item>


<!--                	<el-form-item label="套餐优惠期:"  >
                    <div class="l2 kflexc zidong">
                      <el-select v-model="shopform.yuezu_time" placeholder="输入月" style="width: 100px; margin-right: 10px;">
                        <el-option :value="item" v-for="item in 36" :key="item" :label="item + '个月'"></el-option>
                      </el-select>
                      <div style="margin-right: 10px; color: rgb(51, 51, 51);">优惠期起始时间：</div>
                      <div style="margin-right: 10px; color: rgb(147, 147, 147);">自激活起</div>
                      <el-select v-model="shopform.yuezu_type" placeholder="输入月" style="width: 100px; margin-right: 10px;">
                        <el-option :value="1" label="当月"></el-option>
                        <el-option :value="2" label="次月"></el-option>
                        <el-option :value="3" label="第三月"></el-option>
                      </el-select>
                      <div style="margin-right: 10px; color: rgb(147, 147, 147);">开始</div>
                    </div>
                	</el-form-item>
                  <el-form-item label="佣金结算周期:"  >
                    <div class="l2 kflexc zidong">
                      <el-select v-model="shopform.yongjin_time" placeholder="输入月" style="width: 100px; margin-right: 10px;">
                        <el-option :value="item" v-for="item in 36" :key="item" :label="item + '个月'"></el-option>
                      </el-select>
                      <div style="margin-right: 10px; color: rgb(51, 51, 51);">&nbsp;&nbsp;&nbsp;&nbsp;结算起始时间：</div>
                      <div style="margin-right: 10px; color: rgb(147, 147, 147);">自激活起</div>
                      <el-select v-model="shopform.yongjin_type" placeholder="输入月" style="width: 100px; margin-right: 10px;">
                        <el-option :value="1" label="当月"></el-option>
                        <el-option :value="2" label="次月"></el-option>
                        <el-option :value="3" label="第三月"></el-option>
                      </el-select>
                      <div style="margin-right: 10px; color: rgb(147, 147, 147);">开始</div>
                    </div>
                  </el-form-item>
                  <el-form-item label="返利方式:" >



                    <div class="kflexc" style="margin-bottom: 20px;">
                      <div><el-radio v-model="shopform.fanli_money_type" :label="0">每月相同反费额度</el-radio></div>
                      <div class="kflexc zhouqi" style="margin-left: 20px;">
                          <div style="color: rgb(147, 147, 147); margin-right: 10px;">返费周期:</div>
                          <div>
                            <el-select v-model="shopform.fanli_time" :disabled="shopform.fanli_money_type != 0" placeholder="输入月">
                              <el-option :value="item" v-for="item in 36" :key="item" :label="item + '个月'"></el-option>
                            </el-select>
                          </div>
                          <div style="margin-right: 10px; color: rgb(51, 51, 51); margin-left: 20px;">返利起始时间：</div>
                          <div style="margin-right: 10px; color: rgb(147, 147, 147);">自激活起</div>
                          <el-select v-model="shopform.fanli_type" :disabled="shopform.fanli_money_type != 0" placeholder="输入月" style=" margin-right: 10px;">
                            <el-option :value="1" label="当月"></el-option>
                            <el-option :value="2" label="次月"></el-option>
                            <el-option :value="3" label="第三月"></el-option>
                          </el-select>
                          <div style="margin-right: 10px; color: rgb(147, 147, 147);">开始</div>
                          <div style="margin-right: 10px; color: rgb(147, 147, 147);">每月返费金额</div>
                          <div style="margin-right: 10px; color: rgb(147, 147, 147);"><el-input v-model="shopform.fanli_money" :disabled="shopform.fanli_money_type != 0" placeholder="请输入金额"></el-input></div>
                      </div>

                    </div>


                    <div class="kflex" style=" margin-bottom: 20px;">
                      <div><el-radio v-model="shopform.fanli_money_type" :label="1">每月不同返费额度</el-radio></div>
                      <div style="margin-left: 20px;" v-if="shopform.fanli_money_type == 1">
                        <div class="kflexc" v-for="(item,index) in fanli_money_array" :key="index" style="margin-bottom: 10px;">
                          <div v-if="index == 0">激活当月</div>
                          <div v-if="index == 1">激活次月</div>
                          <div v-if="index != 0 && index != 1">第{{index+1}}个月</div>
                          <div style="margin-left: 10px;"><el-input v-model="fanli_money_array[index]" type="number" placeholder="请输入金额"></el-input></div>
                        </div>
                        <el-button type="text"  v-if="shopform.fanli_money_type == 1" @click="changefanli_money_array()">+ 添加月份</el-button>
                      </div>
                    </div>
                  </el-form-item>

                  <el-form-item label="更新历史订单数据:" >
                    <div class="kflexc">
                      <div>
                                        	  <el-date-picker v-model="times" @change="timechange" type="datetimerange" value-format="yyyy-MM-dd HH:mm:ss" range-separator="至" start-placeholder="开始日期"  end-placeholder="结束日期"></el-date-picker>
                                        	</div>
                                          <el-tooltip class="item" effect="dark"  style="margin-left: 20px;" content="说明：该功能会根据你设置的时间点追溯历史订单，把设置返利数据之前的历史订单按照当前设置数据重新计算并加入到返利池中（通常用于之前忘记设置，后来补充设置返利）
                      注：操作前请确保已完整正确设置返利数据。" placement="top-start">
                                          	<i class="el-icon-question" style="color: #409EFF; font-size: 20px; margin-left: 5px; cursor: pointer;" ></i>
                                          </el-tooltip>
                    </div>

                  </el-form-item>

				  <el-form-item label="返费方式:" >
				  	<div>
				  	  <el-select v-model="shopform.is_rebate" placeholder="输入返费方式" style="margin-right: 10px;">
				  	    <el-option :value="3" label="领取返费"></el-option>
				  	    <el-option :value="2" label="自动返费"></el-option>
				  	    <el-option :value="0" label="不使用返利系统"></el-option>
				  	  </el-select>
				  	</div>
				  </el-form-item> -->
                </div>
                <!-- //到这里 -->
							</el-form>
						</div>
					</div>
					<div class="step" style="text-align: center;">
						<el-button type="danger" @click="jiancha()">确认修改</el-button>
					</div>

				</div>
			</div>
		</div>
		<el-dialog title="自定义抓单ID" :visible.sync="randomlog" width="400px">
			<div class="randomdiv">
				<el-input v-model="randomvalue" @input="randomnumwrite" placeholder="自定义抓单ID"></el-input>
			</div>
			<span slot="footer" class="dialog-footer">
				<el-button @click="randomlog = false">取 消</el-button>
				<el-button type="primary" @click="randomgo" :disabled="randomone">确 定</el-button>
			</span>
		</el-dialog>
		<el-dialog title="自定义产品类型" :visible.sync="taglog" width="400px">
			<div class="protag">
				<el-tag :key="item.id" v-for="item in typelist" closable :disable-transitions="false"
					@close="handleClose(item.name)">{{item.name}}</el-tag>
				<el-input class="input-new-tag" v-if="inputVisible" v-model="inputValue" ref="saveTagInput" size="small"
					@keyup.enter.native="handleInputConfirm" @blur="handleInputConfirm">
				</el-input>
				<el-button v-else class="button-new-tag" size="small" @click="showInput">输入自定义名称</el-button>
			</div>
			<span slot="footer" class="dialog-footer">
				<el-button @click="dialogVisible = false">取 消</el-button>
				<el-button type="primary" @click="dialogVisible = false">确 定</el-button>
			</span>
		</el-dialog>
		<!-- <foot></foot> -->
    <xiugaijilu ref="xiugaijilulog" :id="xiugaijiluall.id" v-if="xiugaijiluall.show"></xiugaijilu>
    <chengjieyongjinjilu ref="chengjieyongjinjilulog" :id="xiugaijiluall.id" v-if="xiugaijiluall.show"></chengjieyongjinjilu>
	</div>
</template>

<script>
	import {
		provinceAndCityDataPlus,provinceAndCityData,
		CodeToText,
		TextToCode
	} from 'element-china-area-data'
	import UploadExcelComponent from "@/components/UploadExcel/index.vue";
	import E from 'wangeditor'
	import axios from 'axios'
	import top from '@/components/top.vue'
	import left from '@/components/left.vue'
	import foot from '@/components/foot.vue'
  import dizhi from '@/views/yonghuyunying/zujian/dizhi.vue'
  import chuantu from "../zujian/chuantu.vue";
  import chuantu2 from "../zujian/chuantu2.vue";
  import zdzd from "./zdzd.vue";
  import xiugaijilu from "./log/xiugaijilu.vue";
  import chengjieyongjinjilu from "./log/chengjieyongjinjilu.vue";

	export default {
		components: {
			"left": left,
			"top": top,
			"foot": foot,
			UploadExcelComponent,
      dizhi,chuantu,chuantu2,zdzd,xiugaijilu,chengjieyongjinjilu
		},
		name: 'myDistributor',
		data() {
			return {
        xiugaijiluall:{
          id:"",
          show:false,
        },
        times:[],
        yugulog:false,
        jiesuanlog:false,
        chuantushow:false,
				taglog: false,
				taglist: ['类型1', '类型2'],
				inputVisible: false,
				inputValue: '',

				mingan: {
					city: "",
					citys: [],
					fixcitys: []
				},
				randomnum: "",
				jingdongrandom: "",
				search: "",
				msg: "hello",
				log: false,
				loading: true,

				typelist: {},
				citylist: provinceAndCityData,

				form: {
					produce_address: "",
					operator: 10099,
					name: "",
					sku: "",
					plan_type_id: "",
					province: "",
					city: [],
					citys: [],
					real_name_type: '0',
					produce_remark: "",
					status: "",
					comname: "",
					min_age: 18,
					max_purchase: 5,

					haochinum: 1,
					haochival: 1,

					address_province: "",
					address_city: "",
					address_district: "",
					commission_rule: "",
          commission_notes:"",
          fanli_money_array:""
				},
				shopform: {
          sign_type:1,
					product_id: "",
					title: "",
					status: "",
					parent_id: "",
					selling_point: "",
					commission_rule: "",
          estimated_income:"",
          commission_notes:"",
					is_need_photo: "0",
					description: "",
					pdd_description: "",
					image1: "",
					imageUrl: '',
					imageUrl2: '',
					details: {
						yuezu: "",
						liuliang: "",
						yuyin: "",
						quanyi: "",
						taocan: ""
					},
					expect_income:"",
					share_img:"",
					auto_transfer:'',
					auto_transfer_sources:[],
					auto_transfer_pages:[],
          commission_rule_change_at:"",
          change_commission_notes:"",
          commission_notes_change_at:"",
          expect_income_change_at:"",
          change_commission_rule:"",
          change_expect_income:"",
          expect_income_new:"",
          fanli_start:"",
          fanli_end:""
				},
        jiesuanlog2:false,
				moneyform: {
					order_page_id: "",
					visible: '1',
					commission: 0,
					child_shop_ids: "",
					dislist: "",
					money: "",
					list: ""
				},
				rules: {
					operator: [{
						required: true,
						message: '必选',
						trigger: 'change'
					}],
          sign_type: [{
            required: true,
            message: '必填',
            trigger: 'change'
          }],
					name: [{
						required: true,
						message: '必填',
						trigger: 'blur'
					}],
					title: [{
						required: true,
						message: '必填',
						trigger: 'blur'
					}],
					proid: [{
						required: true,
						message: '必填',
						trigger: 'blur'
					}],
					sku: [{
						required: true,
						message: '必填',
						trigger: 'blur'
					}],
					city: [{
						required: true,
						message: '请选择活动区域',
						trigger: 'change'
					}],
					real_name_type: [{
						required: true,
						message: '请输入',
						trigger: 'change'
					}],
					randomnum: [{
						required: true,
						message: '请输入抓单码',
						trigger: 'change'
					}],
					// title: [{ required: true, message: '必填', trigger: 'change' }],
					is_need_photo: [{
						required: true,
						message: '必选',
						trigger: 'change'
					}],
					img: [{
						required: true,
						message: '必选',
						trigger: 'change'
					}],
					edit: [{
						required: true,
						message: '必填',
						trigger: 'change'
					}],
					visible: [{
						required: true,
						message: '必选',
						trigger: 'change'
					}],
					commission: [{
						required: true,
						message: '必选',
						trigger: 'change'
					}],
				},
				kejian: false,
				sub1: true,
				sub2: true,
				sub3: true,
				sub4: true,
				showmoney: false,
				sanlist: [
     //      {
					// 	name: "中国联通",
					// 	id: 10000
					// },
					// {
					// 	name: "中国移动",
					// 	id: 10086
					// },
					// {
					// 	name: "中国电信",
					// 	id: 10010
					// },
					{name:"中国广电",id:10099}
				],
				randomvalue: "",
				randomone: false,
				randomlog: false,

				shop_id: "",
				abstract: "",
				statusshop: false,

				prolists: [],


				basis: 0,
				basislog: false,
				proid: "",
				shopid: "",
				shoplists: {},
				basisshop: "",
				semod: 1,
				force_update: false,
				force_updateshow: false,
				shop: "",
				split_list: [],
				cishu:0,
				cd_type_radio:4,
				cd_number:"0",
        guishudi_all:"",

        provinceData: provinceAndCityData,
        cityData: [],
        provinceText: '',
        cityText: '',
        isxn:false,

        fanli_money_array:[]
			}
		},
		created() {
			//权限问题
			var user = JSON.parse(localStorage.getItem('USER'));
			this.shop = user.id
			//获取分销商
			this.getdislist()
			this.getpeizhi()
			//获取类型
			this.getproductstype();
			this.getpros();
			this.getshops()
			axios.get('/api/gth/user/shop')
				.then(response => {
					if (response.data.msg.code == 0) {
						this.shop_id = response.data.data.shop_id


            // if(this.shop_id == 50481 || this.shop_id == 304676){
            //   this.$router.push('/productionDelivery/shangpinall?id='+this.$route.query.id)
            // }

					} else {
						if (response.data.msg.code == 50401) {
							that.$router.push({
								path: "/login"
							});
							return false
						}
						that.$message.error(response.data.msg.info);
					}
				})
		},
		mounted() {

      this.citylist.forEach(item=>{
        if(item.label == '北京市'){
          item.children.forEach(item=>{
            item.label = '北京市'
          })
        }
        if(item.label == '上海市'){
          item.children.forEach(item=>{
            item.label = '上海市'
          })
        }
        if(item.label == '重庆市'){
          item.children.forEach(item=>{
            item.label = '重庆市'
          })
        }
        if(item.label == '天津市'){
          item.children.forEach(item=>{
            item.label = '天津市'
          })
        }
      })

			var that = this
			var editor = new E('#editor');
			editor.customConfig.uploadImgServer = '/upload'
			editor.customConfig.showLinkImg = false
			editor.customConfig.onchange = function(html) {
				if(html=='<p><br></p>'){
					that.shopform.description = ''
				}else{
					that.shopform.description = html
				}

				console.log('===html')
				console.log(html)
			}
			editor.customConfig.onblur = function(html) {
				if(html=='<p><br></p>'){
					that.shopform.description = ''
				}else{
					that.shopform.description = html
				}
				console.log('===html')
							console.log(html)
			}

			editor.customConfig.customUploadImg = function(files, insert) {
				var formData = new FormData();
				formData.append("pic", files[0]);
				axios.post('/api/plan-market/order-page/upload-pic', formData)
					.then(response => {
						if (response.data.msg.code == 0) {
							insert(response.data.data)

						} else {
							that.$message.error(response.data.msg.info);
						}
					})
			}
			editor.create();

			//其它备注
			var editorE = new E('#editorE');
			editorE.customConfig.uploadImgServer = '/upload'
			editorE.customConfig.showLinkImg = false
			editorE.customConfig.onchange = function(html) {
				that.shopform.pdd_description = html
			}
			editorE.customConfig.customUploadImg = function(files, insert) {
				var formData = new FormData();
				formData.append("pic", files[0]);
				axios.post('/api/plan-market/order-page/upload-pic', formData)
					.then(response => {
						if (response.data.msg.code == 0) {
							insert(response.data.data)

						} else {
							that.$message.error(response.data.msg.info);
						}
					})
			}
			editorE.create();

      //套餐详细信息
      var editorE2 = new E('#editorE2');
      editorE2.customConfig.uploadImgServer = '/upload'
      editorE2.customConfig.showLinkImg = false
      editorE2.customConfig.onchange = function(html) {
      	that.shopform.package_text = html
      }
      editorE2.customConfig.customUploadImg = function(files, insert) {
      	var formData = new FormData();
      	formData.append("pic", files[0]);
      	axios.post('/api/plan-market/order-page/upload-pic', formData)
      		.then(response => {
      			if (response.data.msg.code == 0) {
      				insert(response.data.data)
      			} else {
      				that.$message.error(response.data.msg.info);
      			}
      		})
      }
      editorE2.create();

			//获取商品详情后追加内容
			var that = this;
			axios.get('/api/plan-market/order-page2?order_page_id=' + this.$route.query.id)
				.then(response => {
					if (response.data.msg.code == 0) {

            if( response.data.data.selling_point && response.data.data.selling_point != ''){
              response.data.data.selling_point = response.data.data.selling_point.toString()
            }else{
              response.data.data.selling_point = ''
            }

						if (response.data.data.is_need_photo == "0") {
							response.data.data.is_need_photo = "0"
						}
						if (response.data.data.is_need_photo == "1") {
							response.data.data.is_need_photo = "1"
						}
						that.randomnum = response.data.data.fetch_code
						that.jingdongrandom = response.data.data.fetch_code2
						that.shopform = response.data.data
						if (response.data.data.status == 0) {
							that.statusshop = false
						} else {
							that.statusshop = true
						}
						editor.txt.html(that.shopform.description)
						editorE.txt.html(that.shopform.pdd_description)
            editorE2.txt.html(that.shopform.package_text)


						if (that.shopform.parent_id == 0) {
							that.semod = '1'
							that.proid = that.shopform.product_id
						} else {
							that.semod = '2'
							that.shopid = that.shopform.parent_id
						}

						if (that.shopform.parent_id == 0) {
							that.force_updateshow = true
						}
						if (that.shopform.details) {
							that.shopform.details = JSON.parse(that.shopform.details)
						} else {
							that.shopform.details = {
								yuezu: "",
								liuliang: "",
								yuyin: "",
								quanyi: "",
								taocan: ""
							}
						}

            // var city = []
            // if(this.shopform.guishudi_province != "" && this.shopform.guishudi_province != null && this.shopform.guishudi_province != "全部"){
            // 	city.push(TextToCode[this.shopform.guishudi_province].code)
            // }
            // if(this.shopform.guishudi_city != "" && this.shopform.guishudi_city != null){
            // 	city.push(TextToCode[this.shopform.guishudi_province][this.shopform.guishudi_city].code)
            // }
            // this.guishudi_all = city

            if(that.shopform.guishudi_province){
            	 that.provinceText = TextToCode[that.shopform.guishudi_province].code
               that.handleChangeProvince(that.provinceText)
            }
            if(that.shopform.guishudi_city){

            	that.cityText = TextToCode[that.shopform.guishudi_province][that.shopform.guishudi_city].code

            }

			if (that.shopform.is_virtually == 1) {
				that.isxn = true
			} else {
				that.isxn = false
			}

            that.chuantushow = true
            if(that.shopform.fanli_money_array){
              that.fanli_money_array = that.shopform.fanli_money_array.split(',')
            }

						that.loading = false

					} else {
						that.$message.error(response.data.msg.info);
					}
				})

		},
		methods: {
      xiugaijilukai2:function(){
        this.xiugaijiluall.id = this.shopform.expect_income_new_log
        this.xiugaijiluall.show = true
        this.$nextTick(()=>{
          this.$refs.chengjieyongjinjilulog.chushihua()
        })
      },
      xiugaijilukai:function(){
        this.xiugaijiluall.id = this.shopform.commission_note_log
        this.xiugaijiluall.show = true
        this.$nextTick(()=>{
          this.$refs.xiugaijilulog.chushihua()
        })
      },
      timechange:function(){
        if(this.times != null){
        	this.shopform.fanli_start = this.times[0];
        	this.shopform.fanli_end = this.times[1];
        }else{
          this.shopform.fanli_start = ''
          this.shopform.fanli_end = ''
        }
      },

      test1:function(){
        console.log(this.shopform.commission_rule_change_at)
      },
      //添加月份
      changefanli_money_array:function(){
        this.fanli_money_array.push(0)
      },
      getimg:function(img){
        this.shopform.image1 = img
      },
      getimg2:function(img){
        this.shopform.share_img = img
      },
      xuanzhongde:function(item){
        this.shopform.guishudi = item.zi
        this.shopform.guishudi_code = item.shu
        // this.all.province = item
      },
      // handleChangeProvince(value) {
      //       this.cityData = []
      //       this.cityText = ''
      //       const province = CodeToText[value]
      //       if (province === '北京市' || province === '天津市' || province === '上海市' || province === '重庆市' ||
      //         province === '香港特别行政区' || province === '澳门特别行政区') {
      //         const city = { value: value, label: province }
      //         this.cityData.push(city)
      //       } else {
      //         const childList = this.provinceData.find(i => i.value === value).children
      //         this.cityData.push(...childList)
      //       }
      //       console.log(this.provinceText,this.cityText)
      // },
      // guishudi:function(val){
      //   if(val[0] == '全部'){
      //     this.shopform.guishudi_province = ''
      //   }else{
      //     this.shopform.guishudi_province = CodeToText[val[0]]
      //   }
      //   if(val[1] == '全部'){
      //     this.shopform.guishudi_city = ''
      //   }else{
      //     this.shopform.guishudi_city = CodeToText[val[1]]
      //   }
      // },
			jiancha:function(){

			  let arr = []
			  if(this.split_list.length != 0){

			    this.split_list.forEach(item=>{
			      arr.push(item.sku)
			    })

			    axios.post('/api/plan-market/shop/skus/check',{skus:arr})
			    	.then(response => {
			    		if (response.data.msg.code == 0) {
			    			this.shopsave()
			    			this.loading = false
			    		} else {
			    			this.loading = false
			    			this.$message.error('拆分订单所属商品' + response.data.msg.info);
			    		}
			    	})

			  }else{
			    this.shopsave()
			    this.loading = false
			  }



				// this.loading = true
				// if(this.split_list.length != 0){
				// 	this.checksku(this.split_list[0].sku)
				// }else{
				// 	this.shopsave()
				// 	this.loading = false
				// }
			},
			checksku:function(sku){

				// axios.post('/api/plan-market/shop/sku/check',{sku:sku})
				// 	.then(response => {
				// 		if (response.data.msg.code == 0) {
				// 			this.cishu++
				// 			if(this.cishu == this.split_list.length){
				// 				this.shopsave()
				// 				this.cishu = 0
				// 				this.loading = false
				// 			}else{
				// 				this.checksku(this.split_list[this.cishu].sku)
				// 			}
				// 		} else {
				// 			this.cishu = 0
				// 			this.loading = false
				// 			this.$message.error(sku + response.data.msg.info);
				// 			return false
				// 		}
				// 	})
			},
			getpeizhi:function(){
				axios.get('/api/plan-market/split/configs2?page_id=' + this.$route.query.id)
					.then(response => {
						if (response.data.msg.code == 0) {
							console.log('peizhi')
							console.log(response.data.data)
							if(response.data.data.length==0){
								this.cd_number = '0'
							}else{
								this.cd_number = response.data.data.length
							}

							this.split_list = response.data.data
							this.split_list.forEach(item => {
								if(item.check_deliver == 1){
									item.check_deliver = true
									this.cd_type_radio = 4
								}else if(item.check_deliver == 0){
									item.check_deliver = false
									this.cd_type_radio = 4
								}else if(item.check_deliver == 2){
									this.cd_type_radio = 3
								}
							})

						} else {
							this.$message.error(response.data.msg.info);
							return false
						}
					})
			},
			changenumber: function(val) {
				let v = val - this.split_list.length
				if (v > 0) {
					for (let i = 0; i < v; i++) {
						// 当前商品id  拆单商品sku 第几个拆单  是否检测发货1检测0不 later是多少小时后拆单 1=1小时
						this.split_list.push({
							page_id: "",
							sku: "",
							split_number: "",
							check_deliver: "",
							later: ""
						})
					}
				} else {
					this.split_list.length = val
				}
			},
			//强制同步
			changeforce_update: function() {
				console.log("a")
				this.$confirm('勾选后下游所有该商品的下游详情页将同步更新, 是否继续?', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(() => {
					this.force_update = true
				}).catch(() => {
					this.force_update = false
				})
			},
			//更换基础产品
			// basisgo:function(){
			// 	this.loading = true
			// 	var that = this
			// 	if( this.basis == 0){
			// 		axios.post('/api/plan-market/page/product/update',{product_id:this.proid,page_id:this.chooseid})
			// 			.then(response => {
			// 				if(response.data.msg.code == 0){
			// 					that.$message.success("修改成功");
			// 					that.getpro()
			// 					that.basislog = false
			// 				}else{
			// 					that.$message.error(response.data.msg.info);
			// 				}
			// 			})
			// 	}
			// 	if( this.basis == 1){
			// 		axios.post('/api/plan-market/page/product/update',{parent_page_id:this.shopid,page_id:this.chooseid})
			// 			.then(response => {
			// 				if(response.data.msg.code == 0){
			// 					that.$message.success("修改成功");
			// 					that.getpro()
			// 					that.basislog = false
			// 				}else{
			// 					that.$message.error(response.data.msg.info);
			// 				}
			// 			})
			// 	}
			// },
			// getallshop:function(){
			// 	if( this.basis == 0){this.getpros()}
			// 	if( this.basis == 1){this.getshops()}
			// },
			//获取全部基础产品
			getpros: function() {
				var that = this
				axios.get('/api/gth/products/list?page_size=10000')
					.then(response => {
						if (response.data.msg.code == 0) {
							that.prolists = response.data.data.data
							// for(var i in response.data.data.data){
							// 	var obj = {
							// 		name:response.data.data.data[i].name,
							// 		id:response.data.data.data[i].id
							// 	}
							// 	that.prolists.push(obj)
							// }
							// this.getshops()
						} else {
							that.$message.error(response.data.msg.info);
						}
					})

			},
			getshops: function() {
				//获取商品
				var that = this;
				axios.get('/api/gth/supplier/products?page_size=1000')
					.then(response => {
						if (response.data.msg.code == 0) {
							that.shoplists = response.data.data.data
							// for(var i in response.data.data.data){
							// 	var obj = {
							// 		name:response.data.data.data[i].title,
							// 		id:response.data.data.data[i].id
							// 	}
							// 	that.prolists.push(obj)

							// }
						} else {
							if (response.data.msg.code == 50401) {
								that.$router.push({
									path: "/login"
								});
								return false
							}
							that.$message.error(response.data.msg.info);
						}
					})
			},
			//自定义抓单码唯一性
			randomnumwrite: function() {
				var that = this
				axios.get('/api/plan-market/order-page/fetch-code/isexist?fetch_code=' + this.randomvalue)
					.then(response => {
						if (response.data.msg.code == 0) {
							that.randomone = false
						} else {
							that.randomone = true
						}
					})
			},
			//自定义抓单码点击确认
			randomgo: function() {
				this.randomnum = this.randomvalue
				this.randomlog = false
			},
			//获取产品详情
			getprodetail: function() {
				var that = this;
				axios.get('/api/plan-market/product?product_id=' + this.$route.query.productid)
					.then(response => {
						if (response.data.msg.code == 0) {
							this.form = response.data.data

							if (this.form.real_name_type == 0) {
								this.form.real_name_type = "0"
							}
							if (this.form.real_name_type == 1) {
								this.form.real_name_type = "1"
							}

							this.mingan.citys = this.form.warn_province
							this.mingan.fixcitys = this.form.warn_city



							var city = []
							if (this.form.province != "") {
								city.push(TextToCode[this.form.province].code)
							}
							if (this.form.city != "") {
								city.push(TextToCode[this.form.province][this.form.city].code)
							}
							this.form.citys = city


						} else {
							that.$message.error(response.data.msg.info);
						}
					})
			},

			//获取商品品详情
			getshopdetail: function() {
				var that = this;
				axios.get('/api/plan-market/order-page?order_page_id=' + this.$route.query.id)
					.then(response => {
						if (response.data.msg.code == 0) {
							var arr = ""
							for (var i in response.data.data.selling_point) {
								arr = arr + response.data.data.selling_point[i]
							}
							response.data.data.selling_point = arr

							if (response.data.data.is_need_photo == "0") {
								response.data.data.is_need_photo = "0"
							}
							if (response.data.data.is_need_photo == "1") {
								response.data.data.is_need_photo = "1"
							}
							that.randomnum = response.data.data.fetch_code
							that.shopform = response.data.data

						} else {
							that.$message.error(response.data.msg.info);
						}
					})
			},


			//修改佣金时执行全部佣金赋值并保存后重新获取一下列表和佣金
			fixallmoney: function() {
				var that = this;
				var formData = new FormData();
				formData.append("order_page_id", this.moneyform.order_page_id);
				formData.append("visible", this.moneyform.visible);
				formData.append("commission", this.moneyform.commission);
				formData.append("child_shop_ids", this.moneyform.child_shop_ids);

				axios.post('/api/gth/order-page/visible', formData)
					.then(response => {
						if (response.data.msg.code == 0) {
							that.getmoneylist();
						} else {
							that.$message.error(response.data.msg.info);
						}
					})
			},
			//个性化编辑佣金
			fixmoney: function(i, id) {
				this.$prompt('请输入金额', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
				}).then(response => {
					var that = this;
					var formData = new FormData();
					formData.append("order_page_id", that.moneyform.order_page_id);
					formData.append("child_shop_id", id);
					formData.append("commission", response.value);

					axios.post('/api/plan-market/order-page/commissions/update', formData)
						.then(response => {
							if (response.data.msg.code == 0) {
								this.getmoneylist();
								that.$message({
									message: '保存成功！',
									type: 'success'
								});
							} else {
								that.$message.error(response.data.msg.info);
							}
						})
				})
			},
			//获取分销商和佣金
			getmoneylist: function() {
				var that = this;
				axios.get('/api/plan-market/order-page/commissions?order_page_id=' + that.moneyform.order_page_id)
					.then(response => {
						if (response.data.msg.code == 0) {
							that.moneyform.list = response.data.data.data
						} else {
							that.$message.error(response.data.msg.info);
						}
					})
			},

			chakan: function() {
				console.log(this.moneyform.child_shop_ids)
			},
			//产品名验证唯一性
			nijiushiwodeweiyi1: function() {
				var that = this;
				axios.get('/api/plan-market/product/name/isexist?name=' + that.form.name)
					.then(response => {
						if (response.data.msg.code == 0) {
							this.sub1 = true
						} else {
							this.sub1 = false
							that.$message.error(response.data.msg.info);
						}
					})
			},
			//产品编号验证唯一性
			nijiushiwodeweiyi2: function() {
				var that = this;
				axios.get('/api/plan-market/product/sku/isexist?sku=' + this.form.sku)
					.then(response => {
						if (response.data.msg.code == 0) {
							this.sub2 = true
						} else {
							this.sub2 = false
							that.$message.error(response.data.msg.info);
						}
					})
			},
			//商品名验证唯一性
			nijiushiwodeweiyi3: function() {
				var that = this;
				axios.get('/api/plan-market/order-page/name/isexist?title=' + this.shopform.title)
					.then(response => {
						if (response.data.msg.code == 0) {
							this.sub3 = true
						} else {
							this.sub3 = false
							that.$message.error(response.data.msg.info);
						}
					})
			},
			//京东唯一性
			nijiushiwodeweiyi4: function() {
				this.jingdongrandom = this.jingdongrandom.trim()
				if (this.jingdongrandom == "") {
					this.sub4 = true
				} else {
					var that = this;
					axios.get('/api/plan-market/order-page/fetch-code?fetch_code2=' + this.jingdongrandom)
						.then(response => {
							if (response.data.msg.code == 0) {
								this.sub4 = true
							} else {
								this.sub4 = false
								that.$message.error(response.data.msg.info);
							}
						})
				}

			},
			//身份证审核
			cardid: function() {
				this.moneyform.child_shop_ids = "";
				if (this.moneyform.visible == 3 || this.moneyform.visible == 4) {
					this.kejian = true
				}
				if (this.moneyform.visible == 1 || this.moneyform.visible == 2) {
					this.kejian = false
				}
			},
			//获取全部分销商
			getdislist: function() {
				var that = this;
				axios.get('/api/gth/partner/list?page_size=10000')
					.then(response => {
						if (response.data.msg.code == 0) {
							that.moneyform.dislist = response.data.data.data
						} else {
							that.$message.error(response.data.msg.info);
						}
					})
			},
			//保存产品
			productsave: function() {
				//发布还是仅保存

				console.log(this.mingan.citys)
				if (this.form.address_province == undefined) {
					this.form.address_province = this.form.province
					this.form.address_city = this.form.city
				}

				var that = this;
				var formData = {
					product_id: this.$route.query.productid,
					name: this.form.name,
					sku: this.form.sku,
					operator: this.form.operator,
					plan_type_id: this.form.plan_type_id,
					province: this.form.address_province,
					city: this.form.address_city,
					real_name_type: this.form.real_name_type,
					produce_remark: this.form.produce_remark,
					max_purchase: this.form.max_purchase,
					min_age: this.form.max_purchase,
					// status:this.form.status,
					produce_address: this.form.produce_address,
					commission_rule: this.form.commission_rule,
          commission_notes: this.form.commission_notes,
          estimated_income:this.form.estimated_income,

					warn_province: this.mingan.citys,
					warn_city: this.mingan.fixcitys,
					abstract: this.abstract
				}
				axios.post('/api/plan-market/product', formData)
					.then(response => {
						if (response.data.msg.code == 0) {
							that.shopform.product_id = response.data.data.id
							//成功获取到产品id后执行保存商品
							that.shopsave();

						} else {
							that.$message.error(response.data.msg.info);
						}
					})
			},
			//保存商品
			shopsave:function() {

        if(this.shop_id == 304676 || this.shop_id == 50481){
          if(!this.shopform.expect_income_new){
            this.$message.error("承接佣金规则必填");
            return false
          }
          if(!this.shopform.commission_notes){
            this.$message.error("佣金结算规则（内部）");
            return false
          }
        }

		if(!this.shopform.description){
            this.$message.error("请输入商品详情");
            return false
          }

				if (this.sub4 == false) {
					return false
				}
				if (this.jingdongrandom == "" || this.jingdongrandom == null) {

				} else {
					if (this.jingdongrandom.length != 3) {
						this.$message.error("京东抓单码必须三位或者不填写");
						return false
					}
				}
				var that = this;
				// if(this.basis == 0){
				// 	product_id:this.proid
				// 	page_id:this.chooseid
				// 	parent_page_id:this.shopid
				// 	page_id:this.chooseid
				// }

        if(this.provinceText){
          this.shopform.guishudi_province = CodeToText[this.provinceText]
        }else{
          this.shopform.guishudi_province = ""
        }
        if(this.cityText){
          this.shopform.guishudi_city = CodeToText[this.cityText]
        }else{
          this.shopform.guishudi_city = ""
        }

		if(this.shopform.auto_transfer_pages.length){
			if(this.shopform.auto_transfer_pages[0].title==undefined){
				var new_auto_transfer_pages = this.shopform.auto_transfer_pages
			}else{


				var new_auto_transfer_pages = []
				for(var x=0;x<this.shopform.auto_transfer_pages.length;x++){
					new_auto_transfer_pages.push(this.shopform.auto_transfer_pages[x].id)
				}
			}
		}else{
			var new_auto_transfer_pages = this.shopform.auto_transfer_pages
		}

				var formData = {
					order_page_id: this.$route.query.id,
					title: this.shopform.title,
          sign_type: this.shopform.sign_type,

					selling_point: this.shopform.selling_point,
					commission_rule: this.shopform.commission_rule,
          estimated_income: this.shopform.estimated_income,

          commission_notes: this.shopform.commission_notes,

					is_need_photo: this.shopform.is_need_photo,
					description: this.shopform.description,
					pdd_description: this.shopform.pdd_description,
					image1: this.shopform.image1,
					fetch_code: this.randomnum,
					status: this.shopform.status,
					fetch_code2: this.jingdongrandom,
					abstract: this.abstract,
					force_update: this.force_update,
					details: JSON.stringify(this.shopform.details),
          expect_income: this.shopform.expect_income,
          // guishudi_province: this.shopform.guishudi_province,
          // guishudi_city: this.shopform.guishudi_city,
          guishudi: this.shopform.guishudi,
          guishudi_code: this.shopform.guishudi_code,
          yuezu: this.shopform.yuezu,
          liuliang: this.shopform.liuliang,
          yuyin: this.shopform.yuyin,
          yuezu_time: this.shopform.yuezu_time,
          yuezu_type: this.shopform.yuezu_type,
          yongjin_time: this.shopform.yongjin_time,
          yongjin_type: this.shopform.yongjin_type,
          fanli_time: this.shopform.fanli_time,
          fanli_type: this.shopform.fanli_type,
          share_img: this.shopform.share_img,
          dx_liuliang:this.shopform.dx_liuliang,
          package_text:this.shopform.package_text,
          points:this.shopform.points,
		  fanli_money:this.shopform.fanli_money,
		  is_rebate:this.shopform.is_rebate,
		  auto_transfer:this.shopform.auto_transfer,
		  auto_transfer_sources:this.shopform.auto_transfer_sources,
		  auto_transfer_pages:new_auto_transfer_pages,
      fanli_money_type:that.shopform.fanli_money_type,
      fanli_money_array:that.fanli_money_array.toString(),
      commission_rule_change_at:this.shopform.commission_rule_change_at,
      change_commission_notes:this.shopform.change_commission_notes,
      commission_notes_change_at:this.shopform.commission_notes_change_at,
      expect_income_change_at:this.shopform.expect_income_change_at,
      change_commission_rule:this.shopform.change_commission_rule,
      change_expect_income:this.shopform.change_expect_income,
      expect_income_new:this.shopform.expect_income_new,
      fanli_start:this.shopform.fanli_start,
      fanli_end:this.shopform.fanli_end
				}
				if (this.semod == 1) {
					formData['product_id'] = this.proid
				} else {
					formData['parent_id'] = this.shopid
				}

				if (this.isxn == true) {
					formData['is_virtually'] = 1
				} else {
					formData['is_virtually'] = 0
				}



				axios.post('/api/plan-market/order-page', formData)
					.then(response => {
						if (response.data.msg.code == 0) {
							//添加拆单设置
							// if(this.split_list != ''){
								this.split_list.forEach((item,index)=>{
									if(this.cd_type_radio==3){
										//按条件拆单
										item.check_deliver = 2
										item.later = "0"
									}else if(this.cd_type_radio==4){
										//按时间拆单
										if(item.check_deliver == true){
											item.check_deliver = 1
										}else{
											item.check_deliver = 0
										}
									}

									item.page_id = this.$route.query.id
									item.split_number = index+1
								})
								let datas = {
									data:this.split_list,
									page_id:this.$route.query.id
								}

								axios.post('/api/plan-market/split/config2', datas)
									.then(response2 => {
										if (response2.data.msg.code == 0) {
											//下架商品
											if (that.shopform.status == 0) {
												that.$message({
													message: '修改成功！',
													type: 'success'
												});
												that.$router.push({
													path: '/productionDelivery/productionDeliverysale'
												})
											} else {
												//上架商品
												if (this.shop_id == 50481 || this.shop_id == 304676) {
													if (this.statusshop == true) {
														that.$message({
															message: '商品已提交审核！',
															type: 'success'
														});
														that.$router.push({
															path: '/productionDelivery'
														})
													} else {
														that.$message({
															message: '修改成功！',
															type: 'success'
														});
														that.$router.push({
															path: '/productionDelivery'
														})
													}

												} else {
													that.$message({
														message: '修改成功！',
														type: 'success'
													});
													that.$router.push({
														path: '/productionDelivery'
													})
												}
											}
										} else {
											this.$message.error(response2.data.msg.info);
											return false
										}
									})
							// }else{
							// 	//下架商品
							// 	if (that.shopform.status == 0) {
							// 		that.$message({
							// 			message: '修改成功！',
							// 			type: 'success'
							// 		});
							// 		that.$router.push({
							// 			path: '/productionDeliverysale'
							// 		})
							// 	} else {
							// 		//上架商品
							// 		if (this.shop_id == 50481 || this.shop_id == 304676) {
							// 			if (this.statusshop == true) {
							// 				that.$message({
							// 					message: '商品已提交审核！',
							// 					type: 'success'
							// 				});
							// 				that.$router.push({
							// 					path: '/productionDelivery'
							// 				})
							// 			} else {
							// 				that.$message({
							// 					message: '修改成功！',
							// 					type: 'success'
							// 				});
							// 				that.$router.push({
							// 					path: '/productionDelivery'
							// 				})
							// 			}

							// 		} else {
							// 			that.$message({
							// 				message: '修改成功！',
							// 				type: 'success'
							// 			});
							// 			that.$router.push({
							// 				path: '/productionDelivery'
							// 			})
							// 		}
							// 	}
							// }



						} else {
							that.$message.error(response.data.msg.info);
						}
					})
			},

			//绑定佣金分销商
			bangding: function() {
				var that = this;
				var formData = new FormData();
				formData.append("order_page_id", this.moneyform.order_page_id);
				formData.append("visible", this.moneyform.visible);
				formData.append("commission", this.moneyform.commission);
				formData.append("child_shop_ids", this.moneyform.child_shop_ids);

				axios.post('/api/gth/order-page/visible', formData)
					.then(response => {
						if (response.data.msg.code == 0) {
							console.log(that.form.status)
							if (that.form.status == 0) {
								that.$message({
									message: '修改成功！',
									type: 'success'
								});
								that.$router.push({
									path: '/productionDelivery'
								})
							} else {
								if (this.shop_id == 50481 || this.shop_id == 304676) {
									that.$message({
										message: '商品已提交审核！',
										type: 'success'
									});
									that.$router.push({
										path: '/productionDelivery'
									})
								} else {
									that.$message({
										message: '修改成功！',
										type: 'success'
									});
									that.$router.push({
										path: '/productionDelivery'
									})
								}
							}
						} else {
							that.$message.error(response.data.msg.info);
						}
					})
			},

			dataURLtoFile(dataurl, filename) {
			  let arr = dataurl.split(","),
			    mime = arr[0].match(/:(.*?);/)[1],
			    bstr = atob(arr[1]),
			    n = bstr.length,
			    u8arr = new Uint8Array(n);
			  while (n--) {
			    u8arr[n] = bstr.charCodeAt(n);
			  }
			  return new File([u8arr], filename, {
			    type: mime
			  });
			},
			//单个图片上传
			uploadok: function(file) {
				var that = this;
			  console.log(file.raw)
			  var reader = new FileReader()
			  var img = new Image();
			  reader.onload = function(e) {
			       img.src = e.target.result;
			  };
			  var canvas = document.createElement('canvas');
			  var context = canvas.getContext('2d');
			   // base64地址图片加载完毕后
			  let p = new Promise((r,j)=>{
			     img.onload = function () {
			          // 图片原始尺寸
			          var originWidth = this.width;
			          var originHeight = this.height;
			          // 最大尺寸限制
			          var maxWidth = 1920, maxHeight = 1080;
			          // 目标尺寸
			          var targetWidth = originWidth, targetHeight = originHeight;
			          // 图片尺寸超过400x400的限制
			          if (originWidth > maxWidth || originHeight > maxHeight) {
			              if (originWidth / originHeight > maxWidth / maxHeight) {
			                  // 更宽，按照宽度限定尺寸
			                  targetWidth = maxWidth;
			                  targetHeight = Math.round(maxWidth * (originHeight / originWidth));
			              } else {
			                  targetHeight = maxHeight;
			                  targetWidth = Math.round(maxHeight * (originWidth / originHeight));
			              }
			          }
			          // canvas对图片进行缩放
			          canvas.width = targetWidth;
			          canvas.height = targetHeight;
			          // 清除画布
			          context.clearRect(0, 0, targetWidth, targetHeight);
			          // 图片压缩
			          context.drawImage(img, 0, 0, targetWidth, targetHeight);

			          let base64 = canvas.toDataURL("image/jpeg", 0.8); // 压缩后的base64图片
			          let file2 = that.dataURLtoFile(base64, Date.parse(Date()) + ".jpg");
			          r(file2)
			     };
			  })
			  reader.readAsDataURL(file.raw);
			  p.then(files=>{
			    var formData = new FormData();
			    formData.append("pic", files);
			    axios.post('/api/plan-market/order-page/upload-pic', formData)
			    	.then(response => {
			    		if (response.data.msg.code == 0) {
			    			that.shopform.image1 = response.data.data
			    		} else {
			    			that.$message.error(response.data.msg.info);
			    		}
			    	})
			  })
			},
      uploadok2: function(file) {
      	var that = this;
        console.log(file.raw)
        var reader = new FileReader()
        var img = new Image();
        reader.onload = function(e) {
             img.src = e.target.result;
        };
        var canvas = document.createElement('canvas');
        var context = canvas.getContext('2d');
         // base64地址图片加载完毕后
        let p = new Promise((r,j)=>{
           img.onload = function () {
                // 图片原始尺寸
                var originWidth = this.width;
                var originHeight = this.height;
                // 最大尺寸限制
                var maxWidth = 1920, maxHeight = 10800;
                // 目标尺寸
                var targetWidth = originWidth, targetHeight = originHeight;
                // 图片尺寸超过400x400的限制
                if (originWidth > maxWidth || originHeight > maxHeight) {
                    if (originWidth / originHeight > maxWidth / maxHeight) {
                        // 更宽，按照宽度限定尺寸
                        targetWidth = maxWidth;
                        targetHeight = Math.round(maxWidth * (originHeight / originWidth));
                    } else {
                        targetHeight = maxHeight;
                        targetWidth = Math.round(maxHeight * (originWidth / originHeight));
                    }
                }
                // canvas对图片进行缩放
                canvas.width = targetWidth;
                canvas.height = targetHeight;
                // 清除画布
                context.clearRect(0, 0, targetWidth, targetHeight);
                // 图片压缩
                context.drawImage(img, 0, 0, targetWidth, targetHeight);

                let base64 = canvas.toDataURL("image/jpeg", 0.8); // 压缩后的base64图片
                let file2 = that.dataURLtoFile(base64, Date.parse(Date()) + ".jpg");
                r(file2)
           };
        })
        reader.readAsDataURL(file.raw);
        p.then(files=>{
          var formData = new FormData();
          formData.append("pic", files);
          axios.post('/api/plan-market/order-page/upload-pic', formData)
          	.then(response => {
          		if (response.data.msg.code == 0) {
          			that.shopform.share_img = response.data.data
                console.log(that.shopform.share_img)
          		} else {
          			that.$message.error(response.data.msg.info);
          		}
          	})
        })
      },
			//选择省市区
			changeaddress: function(v) {
				this.form.address_province = CodeToText[v[0]],
					this.form.address_city = CodeToText[v[1]],
					console.log("选中的省市" + this.form.address_province + this.form.address_city)
			},
			//导入敏感地区
			exportData: function(data) {
				console.log(data)
				this.mingan.citys = []
				this.mingan.fixcitys = []
				for (var i = 0; i < data.results.length; i++) {
					this.mingan.citys.push(data.results[i]['敏感地区'])
					if (data.results[i]['修改敏感地区'].indexOf(",") > -1) {
						var arr = data.results[i]['修改敏感地区'].split(',')
					} else if (data.results[i]['修改敏感地区'].indexOf("，") > -1) {
						var arr = data.results[i]['修改敏感地区'].split('，')
					} else {
						return false
						that.$message.error("数据出错了，请检查格式");
					}
					var obj = {}
					obj[arr[0]] = arr[1]
					this.mingan.fixcitys.push(obj)
				}
			},
			//获取产品类型
			getproductstype: function() {
				var that = this
				axios.get("/api/gth/plan-type")
					.then(function(response) {
						if (response.data.msg.code == 0) {
							that.typelist = response.data.data
						} else {
							that.$message.error(response.data.msg.info);
						}

					})
			},

			loggo: function() {
				console.log("a")
			},

			//自定义产品类型
			handleClose(tag) {
				this.taglist.splice(this.taglist.indexOf(tag), 1);
			},

			showInput() {
				this.inputVisible = true;
				this.$nextTick(_ => {
					this.$refs.saveTagInput.$refs.input.focus();
				});
			},

			handleInputConfirm() {
				var that = this;
				var formData = new FormData();
				formData.append("name", this.inputValue);
				axios.post('/api/gth/plan-type/release', formData)
					.then(response => {
						if (response.data.msg.code == 0) {
							that.getproductstype();
							that.$message({
								message: '添加成功',
								type: 'success'
							});
						} else {
							that.$message.error(response.data.msg.info);
						}
					})
				let inputValue = this.inputValue;
				if (inputValue) {
					this.taglist.push(inputValue);
				}
				this.inputVisible = false;
				this.inputValue = '';
			},
			// ======监听
			changesw(val){
				//修改自动转单
				console.log(val)
				this.shopform.auto_transfer =val
			},
			surecreate(val){
				//设置转单目标商品：
				console.log(val)
				var arr = []
				for(var x=0;x<val.length;x++){
					arr.push(val[x].id)
				}
				this.shopform.auto_transfer_pages =arr
			},
			handleChange(val){
				//设置转单订单来源
				console.log(val)
				this.shopform.auto_transfer_sources =val

			}
		}

	}
</script>

<style lang="scss" scoped>
  /deep/ .w-e-menu{ z-index: 1001 !important;}
  /deep/ .w-e-text-container{z-index: 1000 !important; }

	.index {

    /deep/ .el-input .el-input__inner{ width:330px;}
    /deep/ .zidong .el-input__inner{ width: 100% !important;}
    // /deep/ .el-message-box__wrapper {
    // 	z-index: 1002 !important;
    // }
		/deep/ #editorE{position: relative; z-index: 9;}
		/deep/ #editor{ position: relative; z-index: 9;
			::v-deep .w-e-text-container{ z-index: 9;}
			::v-deep .w-e-toolbar .w-e-menu{ z-index: 9;}
		}

    .zhouqi{
      /deep/ .el-input .el-input__inner{ width:120px;}
    }


		.loglist {
			display: flex;
			justify-content: space-between;
			margin-bottom: 30px;

			.log_title {
				padding: 7px 10px;
			}
		}

		.listl {
			height: 350px;
			overflow: auto;

			/deep/ .el-input__inner {
				border: none;
				text-align: center
			}
		}

		.list {

			display: flex;
			text-align: center;
			color: #727272;
			line-height: 45px;
			border: 1px #EAEAEA solid;
			margin-top: -1px;

			.th {
				flex: 1;
				background: #F9F9F9;
				font-size: 14px;
			}

			.td {
				flex: 1;
				font-size: 14px;
				border-right: 1px #EAEAEA solid;
			}
		}

		.el-pagination {
			text-align: right;
			margin: 20px 0
		}

		// .el-dialog__wrapper {
		// 	z-index: 19999 !important;
		// }

		.protag {
			/deep/ .el-tag {
				margin-right: 20px;
				margin-bottom: 20px;
			}
		}

		.addpro {


			/deep/ .el-steps {
				width: 100%;
				padding: 30px;
			}

			.step {
				margin-bottom: 20px;
				background: #FFFFFF;

				.redbor {
					.el-input__inner {
						border: 1px #EEF7FF solid;
					}
				}

				.tilte {
					background: #F9F9F9;
					padding-left: 30px;
					line-height: 45px;
					font-size: 14px;

					span {
						background: #B1E4FF;
						color: #FFFFFF;
						float: right;
						line-height: 15px;
						cursor: pointer;
						padding: 5px 0;
						display: block;
						width: 24px;
						text-align: center;
						margin-right: 20px;
						margin-top: 8px;
						border-radius: 14px;
					}
				}

				.w330 {
					/deep/ .el-input__inner {
						width: 330px !important;
					}
				}
        /deep/ .zidong .el-input__inner{ width: 100% !important;}
				.w480 {
					/deep/ .el-input__inner {
						width: 480px !important;
					}
				}

				.con {
					background: #FFFFFF;
					padding: 35px;

					.flex {
						display: flex;
					}

					.ori {
						background: #FBFBFB;
						padding: 20px 10px;

						/deep/ .el-input {
							width: 300px;
						}

						/deep/ .el-form-item {
							margin-bottom: 20px;
						}

						/deep/ .el-form-item__label {
							width: 150px !important;
						}

						.wenhao2 {
							color: #999;
							font-size: 14px;
						}

						.no {
							display: flex;
							align-items: center;

							#drop {
								/deep/ .el-button--primary {
									background: #409EFF
								}
							}

							.nonum {
								background: #409EFF;
								padding: 0px 10px;
								line-height: 35px;
								height: 35px;
								color: #FFFFFF;
								border-radius: 3px;
								display: block;
							}

							.el-button {}

							span {
								margin: 0 20px;
							}
						}

					}
				}

				.haochi {
					padding: 30px;

					/deep/ .el-select {
						margin-left: 20px;
					}
				}

				.btm0 {
					/deep/ .el-button {
						margin-left: 20px;
					}

					/deep/ .el-form-item {
						margin-bottom: 0;
					}
				}

				.label200 .el-form-item__label {
					width: 149px !important;
				}

				/deep/ .avatar-uploader .el-upload {
					border: 1px dashed #d9d9d9;
					border-radius: 6px;
					cursor: pointer;
					position: relative;
					overflow: hidden;
				}

				.avatar-uploader .el-upload:hover {
					border-color: #409EFF;
				}

				.avatar-uploader-icon {
					font-size: 28px;
					color: #8c939d;
					width: 178px;
					height: 178px;
					line-height: 178px;
					text-align: center;
				}

				.avatar {
					width: 178px;
					height: 178px;
					display: block;
				}

				.wenhao {
					background: #B1E4FF;
					color: #FFFFFF;
					line-height: 15px;
					cursor: pointer;
					padding: 5px 11px;
					margin-left: 20px;
					text-align: center;
					border-radius: 14px;
				}
			}

		}
	}
</style>
